﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace RzCorportativo.Views.Administrativo
{
    [Lib.Permissao(HasValidation = true)]
    public partial class Coordenadores : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack)
                return;
            if (this.Request.QueryString["op"] != null && this.Request.QueryString["op"].Equals("ccs"))
            {
                Alert alert = new Alert("erroGeral", this);
                alert.Add("sucesso", "Dados salvos com sucesso!");
                alert.Show();
            }
            List<Lib.Login> logins = Lib.Login.Listar(new Lib.Login() { TipoLogin = Lib.TipoLogin.Interno });
            foreach (var login in logins)
            {
                var row = new System.Web.UI.HtmlControls.HtmlTableRow();

                row.Cells.Add(new System.Web.UI.HtmlControls.HtmlTableCell()
                {
                    InnerText = (login.Usuario ?? new Lib.Usuario()).Nome
                });

                row.Cells.Add(new System.Web.UI.HtmlControls.HtmlTableCell()
                {
                    InnerText = login.LoginText
                });

                row.Cells.Add(new System.Web.UI.HtmlControls.HtmlTableCell()
                {
                    InnerHtml = "<div class='btn-group' data-toggle='buttons-radio'><input type='button' value='gerenciar' class='btn ' onclick='Editar(" + login.LoginId + ")' />" +
                                //"<input type='button' value='permissões' class='btn btn-primary' onclick='EditarPermissao(" + login.LoginId + ")' />" +
                                "<input type='button' value='remover' class='btn btn-danger' onclick='Excluir(" + login.LoginId + ")' /></div>"
                });

                gridCoordenadores.Rows.Add(row);
            }
        }
    }
}